package com.liezh.prototype;

import java.util.HashMap;
import java.util.Map;

/**
 * 简单工厂模式
 * @author liezh
 * @date 2021-9-1
 */
public class SrcFactory {

    private static Map<String, IPrototype> srcMap = new HashMap<>();

    static {
        srcMap.put("Movie", new Movie());
        srcMap.put("Ebook", new Ebook());
    }

    public static IPrototype getInstance(String name) throws CloneNotSupportedException {
        final IPrototype clone = srcMap.get(name).clone();
        return clone;
    }
}
